package com.briup.srms.sms.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.srms.sms.bean.Clazz;
import com.briup.srms.sms.bean.extend.ClazzExtend;
import com.briup.srms.sms.service.IClazzService;
import com.jacky.base.utils.Message;
import com.jacky.base.utils.MessageUtil;
import com.jacky.base.utils.PageVM;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @program: 杰普基础管理系统
 * @description: 班级控制器类
 * @author: charles
 * @create: 2020-12-27 17:22
 **/
@Api(description = "班级相关接口")
@Validated
@RestController
@RequestMapping("/clazz")
public class ClazzController {

	@Autowired
	private IClazzService clazzService;

	@ApiOperation(value = "分页多条件获取班级信息,级联关联的信息")
	@GetMapping("pageQueryFull")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "page", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"),
		@ApiImplicitParam(name = "year", value = "年份", paramType = "query"),
		@ApiImplicitParam(name = "directionId", value = "方向编号",  paramType = "query"),
		@ApiImplicitParam(name = "area", value = "基地", required = true, paramType = "query"),
		@ApiImplicitParam(name = "status", value = "状态", paramType = "query"),
		@ApiImplicitParam(name = "chargeId", value = "班主任编号",  paramType = "query")
	})
	public Message pageQueryFull(int page, int pageSize,String year,Long directionId,String area,String status,Long chargeId) {
        System.out.println("【pageQueryFull】");
		PageVM<ClazzExtend> pageVM = clazzService.pageQueryFull(page, pageSize,year,directionId,area,status,chargeId);
		return MessageUtil.success(pageVM);
	}

	@ApiOperation(value = "分页多条件获取班级信息")
	@GetMapping("pageQuery")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "page", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"),
		@ApiImplicitParam(name = "year", value = "年份", paramType = "query"),
		@ApiImplicitParam(name = "directionId", value = "方向编号",  paramType = "query"),
		@ApiImplicitParam(name = "area", value = "基地", required = true, paramType = "query"),
		@ApiImplicitParam(name = "status", value = "状态", paramType = "query"),
		@ApiImplicitParam(name = "chargeId", value = "班主任编号",  paramType = "query")
	})
	public Message pageQuery(int page, int pageSize,String year,Long directionId,String area,String status,Long chargeId) {
        System.out.println("【pageQueryClazz】");
		PageVM<Clazz> pageVM = clazzService.pageQuery(page, pageSize,year,directionId,area,status,chargeId);
		return MessageUtil.success(pageVM);
	}

	@ApiOperation(value = "通过id删除")
	@ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键", paramType = "query", required = true))
	@GetMapping("deleteById")
	public Message deleteById(long id) {
        System.out.println("【deleteClazzById】");
		clazzService.deleteById(id);
		return MessageUtil.success("删除成功");
	}

	@ApiOperation(value = "保存或更新消息信息", notes = "如果参数中包含id后端认为是更新操作，如果参数中不包含id认为是插入操作")
	@PostMapping("saveOrUpdate")
	public Message saveOrUpdate(Clazz clazz) {
		clazzService.saveOrUpdate(clazz);
		return MessageUtil.success("更新成功");
	}

	@ApiOperation(value = "开班")
	@PostMapping("startClazz")
	public Message startClazz(Clazz clazz) {
		clazzService.startClazz(clazz);

		return MessageUtil.success("开班成功");
	}

	@ApiOperation(value = "结班")
	@GetMapping("finishClazz")
	public Message finishClazz(long id) {
		clazzService.finishClazz(id);
		return MessageUtil.success("结班成功");
	}


}
